#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<functional>
using namespace std;
using ull = unsigned long long;
#define int long long
//using i128 = __int128_t;
inline int inc(int x, int v, int mod) { x += v;return x >= mod ? x - mod : x; }//代替取模+
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 2e3 + 10, M = 1e5 + 10;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}
typedef struct _GL2_fPoint {
    int x;
    int y;
} GL2_fPoint;

void show(_GL2_fPoint p)
{
    cout << p.x << ' ' << p.y << endl;
}

// 计算通过三点的圆的圆心和半径
float circle_from_three_points(const GL2_fPoint& p1, const GL2_fPoint& p2, const GL2_fPoint& p3) {
    float r = 0;
    float cx = 0;
    float cy = 0;
    float x1 = p1.x, y1 = p1.y;
    float x2 = p2.x, y2 = p2.y;
    float x3 = p3.x, y3 = p3.y;

    float A = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
    if (std::abs(A) < 1e-6f) {
        return false;
    }

    float B = (x1 * x1 + y1 * y1) * (y3 - y2) + (x2 * x2 + y2 * y2) * (y1 - y3) + (x3 * x3 + y3 * y3) * (y2 - y1);
    float C = (x1 * x1 + y1 * y1) * (x2 - x3) + (x2 * x2 + y2 * y2) * (x3 - x1) + (x3 * x3 + y3 * y3) * (x1 - x2);
    float D = (x1 * x1 + y1 * y1) * (x3 * y2 - x2 * y3) + (x2 * x2 + y2 * y2) * (x1 * y3 - x3 * y1) + (x3 * x3 + y3 * y3) * (x2 * y1 - x1 * y2);

    cx = -B / (2 * A);
    cy = -C / (2 * A);
    r = std::sqrt((x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy));
    
    return r;
}

void solve()
{
    int n,m;
    cin >> n >> m;
    string ans;
    if(n == m)
    {
        cout << "NO" << endl;
        return;
    }
    char ss = 'a';
    for(int i = 1; i <= m; i ++)
    {
        ans += ss;
        ss ++;
    }
    char sq = ss - 1; 
    if(n - m > 26)
    {
        cout << "NO" << endl;
        return;
    }
    for(int i = m + 1; i <= n - m; i ++)
    {
        ans += ss;
        ss ++;
    }
    for(int i = 1; i <= m; i ++)
    {
        ans += ss;
        ss++;
    }
    cout << "YES" << endl;
    cout << ans << endl;

}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    tt = 1;
    cin >> tt;
    while (tt--)
    {
        solve();
    }
}